from django.db import models
import django.utils.timezone as timezone
from simditor.fields import RichTextField

from users.models import UserProfile
# Create your models here.


class Diary(models.Model):
    date = models.DateField(default=timezone.now, verbose_name=u'日期')
    weather = models.CharField(max_length=15, default='', verbose_name=u'天气')
    content = RichTextField(default='', verbose_name=u'内容')
    title = models.CharField(max_length=100, verbose_name=u'标题', default='', blank=True)
    tags = models.CharField(max_length=100, verbose_name=u'标签', default='', blank=True)
    user = models.ForeignKey(UserProfile, on_delete=models.CASCADE, verbose_name=u'所属用户')

    add_time = models.DateTimeField(auto_now_add=True, verbose_name=u'添加时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name=u'修改时间')

    class Meta:
        verbose_name = u'日记内容'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title
